<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>添加任务</title>
    <link rel="stylesheet" type="text/css" href="../../easyui/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="../../easyui/themes/icon.css">
    <script type="text/javascript" src="../../easyui/jquery.min.js"></script>
    <script type="text/javascript" src="../../easyui/jquery.easyui.min.js"></script>
</head>

    <script type="text/javascript">

        <!--页面加载完成后查询员工信息-->

        $(function () {

            $.ajax({

                url:"task/list",
                success:function (data) {
                    var str='';
                    for (var i = 0; i < data.length; i++) {
                        str+='<option value="'+data[i].userId+'">'+data[i].userName+'</option>'
                    }
                    console.log(str)
                    $("#sel").html(str)
                }

            })

        })

        //提交按钮绑定一个单击事件，提交表单
        function submitForm() {
            $('#ff').form('submit', {
                url:"task/addTask",
                success:function (data) {
                    if (data==1){
                        $.messager.alert("提示","提交成功","info")
                    }
                }
            });
        }

    </script>

<body>

<div class="easyui-panel" title="添加任务" style="text-align: center">
    <form id="ff" method="post">
        <div style="margin-bottom:20px">
            <input class="easyui-textbox" name="taskName" style="width:400px" data-options="label:'任务标题:',required:true">
        </div>

        <div style="margin-bottom:20px">
            <input class="easyui-datebox" name="startTime" label="开始时间:" data-options="formatter:myformatter,parser:myparser" style="width:400px;">
        </div>

        <div style="margin-bottom:20px">
            <input class="easyui-datebox" name="endTime" label="结束时间:" data-options="formatter:myformatter,parser:myparser" style="width:400px;">
        </div>

        <div style="margin-bottom:20px">
            <input class="easyui-textbox" name="taskDesc" style="width:400px;height:60px" data-options="label:'任务描述:',multiline:true">
        </div>
        <div style="margin-bottom:20px">
            <select class="easyui-combobox" name="taskIsUrgent" label="紧急程度" style="width:400px">
                <option value="0">紧急</option>
                <option value="1">不紧急</option>
            </select>
        </div>
        <div style="margin-bottom:20px">
            执行人：<select id="sel" name="implementId"  style="width:200px">

            </select>
        </div>
    </form>
    <div style="text-align:center;padding:5px 0">
        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()" style="width:80px">添加</a>
    </div>
</div>

</body>
</html>
<script type="text/javascript">
    function myformatter(date){
        var y = date.getFullYear();
        var m = date.getMonth()+1;
        var d = date.getDate();
        return y+'-'+(m<10?('0'+m):m)+'-'+(d<10?('0'+d):d);
    }
    function myparser(s){
        if (!s) return new Date();
        var ss = (s.split('-'));
        var y = parseInt(ss[0],10);
        var m = parseInt(ss[1],10);
        var d = parseInt(ss[2],10);
        if (!isNaN(y) && !isNaN(m) && !isNaN(d)){
            return new Date(y,m-1,d);
        } else {
            return new Date();
        }
    }
</script>